package agg

const (
	NULL int = iota
	START
	CLEAN
)

var rules [][]rune = [][]rune{
	{':', '='},
	{'{'},
	{',', '}', '&', '('},
}

func CleanRune(input []rune) {
	status := NULL
	for i, v := range input {
		switch status {
		case NULL:
			for _, r := range rules[NULL] {
				if r == v {
					status = START
					input[i] = ' '
					break
				}
			}
		case START:
			find := false
			for _, r := range rules[START] {
				if r == v {
					find = true
					break
				}
			}
			if find {
				status = NULL
			} else {
				status = CLEAN
			}
			input[i] = ' '
		case CLEAN:
			find := false
			for _, r := range rules[CLEAN] {
				if r == v {
					find = true
					break
				}
			}
			if find {
				status = NULL
			}
			input[i] = ' '
		}
	}
}
